package org.esky.xml;

import java.io.File;
import java.util.Iterator;

import org.dom4j.io.SAXReader;

public class Dom4jXMLReader {

	/**
	 * DOM4J方式
	 * 
	 * @Title: reader
	 * @Description: TODO
	 * @return: void
	 */
	@SuppressWarnings("rawtypes")
	public static void reader(String path) {
		long lasting = System.currentTimeMillis();
		try {
			File f = new File(path);
			SAXReader reader = new SAXReader();
			org.dom4j.Document doc = reader.read(f);
			org.dom4j.Element root = doc.getRootElement();
			org.dom4j.Element foo;
			for (Iterator i = root.elementIterator("node"); i.hasNext();) {
				foo = (org.dom4j.Element) i.next();
				System.out.println("|| Name:  |" + foo.elementText("name"));
				System.out.println("||Space:  |" + foo.elementText("space"));
				System.out.println("-------------------------------------------------");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("DOM4J RUNTIME：" + (System.currentTimeMillis() - lasting) + " MS");
	}
}
